<template>
	<view class="page">
		<view class="top-box">
			<text>我的余额</text>
			<view class="content">
				<text>{{textVal}}</text>
				<view class="btn" @click="goTabBar('/pages/tabShop/index')">
					提现
				</view>
			</view>
		</view>
		<view class="arrLabel">
			<view class="title">
				明细
			</view>
			<view class="typeArr">
				<u-dropdown ref="uDropdown">
						<u-dropdown-item v-model="typeVal" title="余额类型" :options="options">
							<view class="slot-content" style="background-color: #FFFFFF;">
									<view v-for="(item,index) in options" :key="index" @click="changeSelectType(item.value)" :class="item.value==typeVal ? 'selectItem activeColor' : 'selectItem'" >
										{{item.label}}
									</view>
							</view>
						</u-dropdown-item>
				</u-dropdown>
			</view>
		</view>
		<scroll-view scroll-y @scrolltolower="scrolltolower" class="arr">
			<view class="arrItem" v-for="(item,index) in arr" :key="index">
				<view class="left-box">
					<view class="name">
						{{item.remark}}
					</view>
					<text>	
						{{item.create_time_text}}
					</text>
				</view>
				<view class="price">
					{{item.account_data}}
				</view>
			</view>
			<noMore v-if="!arr.length"></noMore>
		</scroll-view>
		
	</view>
</template>

<script>
	import noMore from '@/components/noMore/noMore.vue'
	export default {
		data() {
			return {
				textVal:'',
				typeArr: [
					{
						label : '收入',
						id : 1, 
					},
					{
						label : '支出',
						id : -1, 
					},
				],
				arr:[],
				typeVal : '',
				options:[ 
					{
						label: '默认排序',
						value: 1,
					},
					{
						label: '距离优先',
						value: 2,
					},
					{
						label: '价格优先',
						value: 3,
					}
				],
				page: 1,
				
			}
		},
		components:{
			noMore
		},
		onLoad() {
		},
		onShow() {
			this.getMemberInfo()
			this.getDetailArr()
			this.getType()
		},
		methods:{
			changeSelectType(_value){
				this.typeVal = _value
				this.$refs.uDropdown.close();
			},
			scrolltolower(){
				this.params.page++
				this.getDetailArr()
			},
			getType(){
				this.myHttp({
					url:"/api/Memberaccount/accountTypeList",
					data:{
						account_type : 'balance'
					}
				}).then((res)=>{
					this.options = res.data.list
				})
			},
			getDetailArr(){
				this.myHttp({
					url:'/api/memberaccount/accountList',
					data:{
						page_size: 10,
						page: this.page,
						type: this.typeVal,
						account_type : 'balance',
					}
				}).then((res)=>{
						if(this.page==1){
							this.arr = []
						}
						this.arr = this.arr.concat(res.data.list) 
				})
			},
			getMemberInfo(){
				this.myHttp({
					url:'/api/member/userInfo',
				}).then((res)=>{
					this.memberInfo = res.data
					this.textVal = res.data.balance//余额
					// this.amountArr[1].val = res.data.point//积分
					// this.amountArr[2].val = res.data.coupon //优惠券
				})
			},
		},
		watch:{
			typeVal(){
				this.getDetailArr()
			}
		},
		components:{
			
		},
		filters:{
			
		},
	}
</script>

<style lang="scss" scoped>
.page{
	padding: 25rpx;
	font-family: PingFang SC;
	.top-box{
		width: 700rpx;
		height: 242rpx;
		background: linear-gradient(98deg, #FF4E00, #FF0101);
		border-radius: 20rpx;
		padding:46rpx 21rpx 0 44rpx ;
		text{
			font-size: 24rpx;
			color: #fff;
		}
		.content{
			display: flex;
			justify-content: space-between;
			align-items: center;
			margin-top: 10rpx;
			text{
				font-size: 72rpx;
				font-weight: bold;
				color: #FFFFFF;
			}
			.btn{
				width: 136rpx;
				height: 43rpx;
				border: 2rpx solid #FFFFFF;
				border-radius: 22rpx;
				display: grid;
				place-items: center;
				font-size: 24rpx;
				color: #fff;
			}
		}
	}
	.arrLabel{
		display: flex;
		justify-content: space-between;
		align-items: center;
		margin-top: 52rpx;
		.title{
			color: #010101;
			font-size: 30rpx;
		}
		.activeText{
			font-size: 30rpx;
			color: #010101;
		}
		
		text{
			color: #BCBCBC;
			margin-left: 83rpx;
			&:nth-child(1){
				margin-left: 0;
			}
		}
		.typeArr{
			display: flex;
			.selectItem{
				padding: 30rpx 0;
				@include flexCenter;
				
			}
			.activeColor{
				color: #007AFF !important;
			}
		}
	}
	.arr{
		margin-top: 40rpx;
		height: 65vh;
		.arrItem{
			width: 700rpx;
			height: 126rpx;
			background: #FFFFFF;
			border-bottom: 2rpx solid #eee;
			border-radius: 10rpx;
			display: flex;
			align-items: center;
			justify-content: space-between;
			.left-box{
				height: 100%;
				display: flex;
				flex-direction: column;
				justify-content: center;
				.name{
					margin-bottom: 21rpx;
					font-size: 28rpx;
					color: #000;
				}
				text{
					color: #818181;
				}
			}
			.price{
				color: #000;
				font-weight: 600;
				font-size: 33rpx;
			}
		}
	}
}
</style>
